Straight Lines
Memory limit: 32 MB
We are given six integers: , , , ,
, such that .
These numbers are coefficients in equations of two intersecting lines:
-
,
-
.
The lines divide the plane into four parts.
We represent each part by any point with integer coordinates, belonging to this part
(but not belonging to any of the lines
,
).
You are given a point
with integer coordinates representing one part. Find a point with integer coordinates
representing the same part, such that its distance from the point of intersection
of lines
and
is least possible.
Task
Write a program which:
-
reads the equations of lines and and a point
representing one part of plane,
-
finds a point with integer coordinates representing the given part
and closest to the point of intersection of lines and ,
- writes the answer to the standard output.
Input
The first line of the standard input contains three numbers
, separated by single spaces -
the coefficients of 's equation.
The second line contains three numbers , separated by single spaces -
the coefficients of 's equation.
It is true that .
The third and last line contains two integers ,
separated by a single space. They are the coordinates of a point
representing one part of plane.
Point does not belong to any of lines , .
For every number from the input it is true that
.
Output
Your program should write to the standard output two numbers
, separated by a single space - the coordinates of a point
representing the given part, closest to the point of
intersection of lines and .
If there are many such points, your program should output only
one of them.
Example
For the input data:
1 -1 1
2 -3 1
5 4
the correct result is:
2 2
Task author: Jakub Pawlewicz.